#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'libb@anchent.com'

import time
from random import randint
from threading import Thread


class MyThread(Thread):
    def __init__(self, name):
        super(MyThread, self).__init__()
        self._filename = name

    def run(self):
        print("MyThread start run %s" % self._filename)
        download_time = randint(5, 10)
        time.sleep(download_time)
        print("%s download finished time:%d" % (self._filename, download_time))


if __name__ == '__main__':
    start = time.time()
    thread_list = []
    for i in range(10):
        t = MyThread(str(i))
        t.start()
        thread_list.append(t)

    for j in thread_list:
        j.join()

    end = time.time()
    print("total cost time %.3f" % (end - start))
